<template>
	<view>
		<web-view :src="fileUrl"></web-view>
	</view>
</template>

<script>
	import config from '@/config'
	import {
		Base64
	} from '@/utils/js-base64.js'

	export default {
		data() {
			return {
				title: '',
				fileUrl: ''
			}
		},
		onLoad(params) {
			const url = params.url
			let _url = url.replace('/minio//', '/minio/')
			this.fileUrl =
				`${config.staticUrl}/file-view/onlinePreview?url=${encodeURIComponent(Base64.encode(_url))}&officePreviewType=pdf`
		},
		onShow() {
			const eventChannel = this.getOpenerEventChannel()
			eventChannel.emit('startTime')
		},
		onHide() {
			const eventChannel = this.getOpenerEventChannel()
			eventChannel.emit('saveTime')
		},
		beforeDestroy() {
			const eventChannel = this.getOpenerEventChannel()
			eventChannel.emit('saveTime')
		}
	}
</script>

<style>
</style>
